#if !defined(AFX_MGCONFIGURATIONDIALOG_H__82C8DBE7_EEEC_4998_B75A_7DCA10CDB05B__INCLUDED_)
#define AFX_MGCONFIGURATIONDIALOG_H__82C8DBE7_EEEC_4998_B75A_7DCA10CDB05B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MGConfigurationDialog.h : header file
//

#include "resource.h"
#include <afxtempl.h>
#include "CommandListBox.h"
#include "IDCombo.h"
#include "checksum.h"

/////////////////////////////////////////////////////////////////////////////
// CMGConfigurationDialog dialog

class CMGConfigurationDialog : public CDialog
{
	// Construction
public:
	CMGConfigurationDialog(CWnd* pParent = NULL);   // standard constructor
	
	// Dialog Data
	//{{AFX_DATA(CMGConfigurationDialog)
	enum { IDD = IDD_MOUSE_GESTURE_CONFIGURATION };
	CButton			c_buLoadGestures;
	CButton			c_buSaveGestures;
	CButton			c_buApply;
	CButton			c_cbEnableDoubleClickScrolling;
	CButton			c_cbUseMiddleButtonForDoubleClickScrolling;
	CButton			c_cbPageUpDown;
	CButton			c_cbPageTopBottom;
	CSpinButtonCtrl	c_spPageTopBottomRecognitionArea;
	CEdit			c_edPageTopBottomRecognitionArea;
	CButton			c_buWheelUp;
	CButton			c_buWheelDown;
	CButton			c_cbEnableMGSuspendingKey;
	CButton			c_cbEnableMG;
	CButton			c_cbIdentifyTargetWindowClass;
	CButton			c_cbShowGestureRecognitionOnStatusBar;
	CSpinButtonCtrl	c_spDetectingRepeatedSameDirectionRate;
	CEdit			c_edDetectingRepeatedSameDirectionRate;
	CButton			c_rbMiddleButton;
	CButton			c_rbRightButton;
	CListCtrl		c_lcRegisteredMouseGesture;
	CButton			c_cbPreemptiveMGAButtonAlways;
	CButton			c_buUp;
	CButton			c_buDown;
	CButton			c_buRight;
	CButton			c_buLeft;
	CButton			c_buBackspace;
	CButton			c_buRightButton;
	CButton			c_buLeftButton;
	CButton			c_buMiddleButton;
	CSpinButtonCtrl	c_spGestureRecognitionSensitivity;
	CEdit			c_edGestureRecognitionSensitivity;
	CEdit			c_edGestureInput;
	CButton			c_buDefault;
	CButton			c_rbCTRLKey;
	CButton			c_rbSHIFTKey;
	CButton			c_rbALTKey;
	CCommandListBox	c_lbCommand;
	CStatic			c_xCommandDescription;
	CIDCombo		c_cbCategory;
	CButton			c_buAdd;
	CButton			c_buRemove;
	CButton			c_cbAutoloadingOnStartup;
	//}}AFX_DATA
	
	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMGConfigurationDialog)
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL
	
	// Implementation
protected:
	void UpdateControls();
	void UpdateRegistredGestureList();
	void DoChecksum(checksum &rChecksum);
	void UpdateChecksum() 
	{
		m_checksum.clear();
		DoChecksum(m_checksum); 
	}
	BOOL IsModified() 
	{
		checksum checksum;
		checksum.clear();
		DoChecksum(checksum);
		return checksum.get() != m_checksum.get(); 
	}
	void UpdateMGOptions(BOOL bSaveAndValidate = TRUE);
	
	
	// Generated message map functions
	//{{AFX_MSG(CMGConfigurationDialog)
	virtual void OnOK();
	virtual void OnCancel();
	virtual BOOL OnInitDialog();
	afx_msg void OnSelchangeCbCategory();
	afx_msg void OnSelchangeLbCommand();
	afx_msg void OnBuUp();
	afx_msg void OnBuLeft();
	afx_msg void OnBuRight();
	afx_msg void OnBuDown();
	afx_msg void OnBuWheelUp();
	afx_msg void OnBuWheelDown();
	afx_msg void OnBuLeftButton();
	afx_msg void OnBuMiddleButton();
	afx_msg void OnBuRightButton();
	afx_msg void OnBuBackspace();
	afx_msg void OnBuAdd();
	afx_msg void OnKillfocusEdPageTopBottomRecognitionArea();
	afx_msg void OnKillfocusEdGestureRecognitionSensitivity();
	afx_msg void OnKillfocusEdDetectingRepeatedSameDirectionRate();
	afx_msg void OnBuLoadGestures();
	afx_msg void OnBuSaveGestures();
	afx_msg void OnBuApply();
	afx_msg void OnBuDefault();
	afx_msg void OnItemchangedLcRegisteredMouseGestures(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBuRemove();
	afx_msg void OnButtonClicked();
	afx_msg void OnEditChanged();
	afx_msg void OnChangeEdGestureInput();
	afx_msg void OnKillfocusLcRegisteredMouseGestures(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
	afx_msg void OnInfoTip(NMHDR* pNMHDR, LRESULT* pResult);
	DECLARE_MESSAGE_MAP()
		
private:
	BOOL m_bInitDialog;
	checksum m_checksum;
	BOOL m_bWheelCommand;
	int m_nGestureSelected;
	
	static IDData VSCommandCategories[];
	
	void EnumLoadedResources();
	int ExtractCommandsFromResource(const BYTE * lpbBuffer, DWORD dwResourceSize);
	
	static BOOL CALLBACK EnumNamesFunc(HANDLE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam);
	static BOOL CALLBACK EnumLangsFunc(HANDLE hModule, LPCTSTR lpType, LPCTSTR lpName, WORD wLang, LONG lParam);
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MGCONFIGURATIONDIALOG_H__82C8DBE7_EEEC_4998_B75A_7DCA10CDB05B__INCLUDED_)
